//
//  GRUltimateShopViewCell.m
//  YC_GRice
//
//  Created by Feng Liu on 2018/9/22.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRUltimateShopViewCell.h"

@implementation GRUltimateShopViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    if (KscreenWidth == 320) {
        self.topLayout.constant     = 5;
        self.bottomLayout.constant = 2;
        self.shopName.font = [UIFont boldSystemFontOfSize:15];
    }
    
    self.shopIMG.layer.masksToBounds = YES;
    
    //添加四个边阴影
    self.IMgShadow.layer.shadowColor    = [HEXCOLOR(0x000000) colorWithAlphaComponent:0.18].CGColor;
    self.IMgShadow.layer.shadowOffset   = CGSizeMake(0, 3);
    self.IMgShadow.layer.shadowOpacity = 1;
    self.IMgShadow.layer.shadowRadius   = 4;
    
    CGFloat height = KscreenWidth/3 -16;

    CGRect bounds = CGRectMake(0, 0, height * 20 / 11, height);
    self.IMgShadow.layer.shadowPath      = [UIBezierPath bezierPathWithRect:bounds].CGPath;
}

-(void)setShopModel:(GRUltimateShopModel *)shopModel {
    [self.shopIMG sd_setImageWithURL:[NSURL URLWithString:shopModel.mainPhoto]];
    self.shopName.text = shopModel.nickname;
    NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
    attachment.image   = [UIImage imageNamed:@"Home_14"];
    attachment.bounds = CGRectMake(2, 0, 9, 10);
    NSAttributedString *imageAch = [NSAttributedString attributedStringWithAttachment:attachment];
    NSMutableAttributedString *attstring = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ | %@",shopModel.categoryName, shopModel.distance]];
    [attstring insertAttributedString:imageAch atIndex:shopModel.categoryName.length + 2];
    self.shopDescription.attributedText = attstring;
}

@end
